package com.dragon.datastructure.hash;

import java.util.Objects;

/**
 * 学生类
 *
 * @author dragon
 * @since 2019/12/27
 */
public class Student {

    private String name;

    private Double grade;

    private Integer cls;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getGrade() {
        return grade;
    }

    public void setGrade(Double grade) {
        this.grade = grade;
    }

    public Integer getCls() {
        return cls;
    }

    public void setCls(Integer cls) {
        this.cls = cls;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Student)) {
            return false;
        }
        Student student = (Student) o;
        return Objects.equals(name, student.name) &&
                Objects.equals(grade, student.grade) &&
                Objects.equals(cls, student.cls);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash = hash * 31 + (name == null ? 0 : name.hashCode());
        hash = hash * 31 + (grade == null ? 0 : grade.hashCode());
        hash = hash * 31 + (cls == null ? 0 : cls.hashCode());

        return hash;
    }

    public static void main(String[] args) {
        Student s1 = new Student();
        System.out.println(s1.hashCode());
        Student s2 = new Student();
        System.out.println(s2.hashCode());
    }
}
